var fs = require('fs')

var city_data = './city.json';

var city_confg = fs.readFileSync(city_data).toString();

try{
	eval(city_confg);

}catch(e){

	throw e;
}

exports.mapping = function(data){
	data.ispcn = 'unknown';
	data.provcn ='unknown';
	data.citycn ='unknown';
	for(i=0;i<isp.length;i++){
		if(data.info.indexOf(isp[i].ispcn)!=-1||isp[i].ispcn.indexOf(data.info)!=-1){
			data.ispcn = isp[i].ispcn;
			data.ispid = isp[i].id;
		}
	}
	for(i=0;i<prov.length;i++){
		if(data.contry.indexOf(prov[i].provcn)!=-1||prov[i].provcn.indexOf(data.contry)!=-1){
			data.provcn = prov[i].provcn;
			data.provid = prov[i].id;
		}
	}
	for(i=0;i<city.length;i++){
		if(data.contry.indexOf(city[i].citycn)!=-1||city[i].citycn.indexOf(data.contry)!=-1){
			data.citycn = city[i].citycn;
			data.cityid = city[i].id;
		}
	}
	//data.ispcn = type
	return data;
}